package usaco;
/*
ID: toregg1
LANG: JAVA
TASK: ride
 */
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class ride {
	public static void main(String[] args) throws IOException{
		final int M = 47;
		BufferedReader br = new BufferedReader(new FileReader("ride.in"));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("ride.out")));
		String comet = br.readLine();
		String gronp = br.readLine();
		if((productOfStr(gronp) % M) == (productOfStr(comet) % M)){
			pw.print("GO");
			System.out.println("GO");
		}else{
			pw.print("STAY");
			System.out.println("S");
		}
		pw.close();
	}
	
	private static int productOfStr(String str){
		int temp = 1;
		for(int i = 0; i < str.length(); i++){
			temp *= str.charAt(i) - 'A' + 1;
		}
		return temp;
	}
}
